package com.business.user.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.business.common.dto.R;
import com.business.user.entity.MemberOrder;
import com.business.user.utils.PageFactory;
import com.business.user.service.MemberOrderService;

/**
 * 会员充值订单: 后端controller类
 * @author chenjiehong
 * @date 2019-11-29 14:28:27
 * @since 1.0
 */
@RestController
@RequestMapping(value = "/memberOrder")
public class MemberOrderController {
    
    
    @Autowired
    private MemberOrderService memberOrderServiceImpl;
    
    
    /**
     * 新增会员充值订单
     * 
     * 
     * @param memberOrder
     * @date 2019-11-29 14:28:27
     */
    @PostMapping("/add")
    @ResponseBody
    public R add(@RequestBody MemberOrder memberOrder){
        return R.success(memberOrderServiceImpl.add(memberOrder));
    }
    
    
    /**
     * 查询会员充值订单
     * 
     * 
     * @param params
     * @date 2019-11-29 14:28:27
     */
    @PostMapping("/query")
    @ResponseBody
    public R query(@RequestBody JSONObject params){
        Integer id = params.getInteger("id");
        return R.success(memberOrderServiceImpl.query(id));
    }
    
    
    /**
     * 分页查询会员充值订单
     * 
     * 
     * @param params
     * @date 2019-11-29 14:28:27
     */
    @PostMapping("queryPage")
    @ResponseBody
    public R queryPage(@RequestBody JSONObject params){
        Page<MemberOrder> page = new PageFactory<MemberOrder>().defaultPage(params);
        MemberOrder memberOrder = JSONObject.parseObject(params.toJSONString(),MemberOrder.class);
        return R.success(memberOrderServiceImpl.queryPage(page,memberOrder));
    }

    
    
}